﻿CREATE TABLE [dbo].[Project] (
    [ProjectId]        UNIQUEIDENTIFIER NOT NULL,
    [Name]             NVARCHAR (500)   NOT NULL,
    [Contact]          NVARCHAR (500)   NULL,
    [SaleServiceId]    UNIQUEIDENTIFIER NULL,
    [Objective]        NVARCHAR (MAX)   NULL,
    [PlannedStartDate] DATETIME         NULL,
    [PlannedEndDate]   DATETIME         NULL,
    [PlannedProgress]  INT              NULL,
    [EstimatedEndDate] DATETIME         NULL,
    [ActualStartDate]  DATETIME         NULL,
    [ActualEndDate]    DATETIME         NULL,
    [ActualProgress]   INT              NULL,
    [ManagerId]        UNIQUEIDENTIFIER NULL,
    [StatusCode]       INT              NULL,
    [CreatedOn]        DATETIME         NULL,
    [CreatedById]      UNIQUEIDENTIFIER NULL,
    [ModifiedOn]       DATETIME         NULL,
    [ModifiedById]     UNIQUEIDENTIFIER NULL,
    [IsDeleted]        BIT              NOT NULL,
    [ContractId]       UNIQUEIDENTIFIER NULL,
    [LatestFeadbackOn] DATETIME         NULL,
    [CustomerId]       UNIQUEIDENTIFIER NULL,
    [ProjectTypeCode]  INT              NULL,
    [TechnologyCode]   INT              NULL,
    [ProbabilityCode]  INT              NULL,
    [VersionNumber]    ROWVERSION       NULL,
    CONSTRAINT [PK_Project] PRIMARY KEY CLUSTERED ([ProjectId] ASC),
    CONSTRAINT [FK_Project_Contract] FOREIGN KEY ([ContractId]) REFERENCES [dbo].[Contract] ([ContractId]),
    CONSTRAINT [FK_Project_User] FOREIGN KEY ([ManagerId]) REFERENCES [dbo].[User] ([UserId]),
    CONSTRAINT [FK_Project_User_CreatedBy] FOREIGN KEY ([CreatedById]) REFERENCES [dbo].[User] ([UserId]),
    CONSTRAINT [FK_Project_User_ModifiedBy] FOREIGN KEY ([ModifiedById]) REFERENCES [dbo].[User] ([UserId]),
    CONSTRAINT [FK_Project_User_SaleServiceId] FOREIGN KEY ([SaleServiceId]) REFERENCES [dbo].[User] ([UserId])
);

